﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TextEditor.TextDocument.Data
{
    public class Singleton<T> where T : new()
    {
        private static readonly object syncObject = new object();
        private static T singleton;

        public static T Instance
        {
            get
            {
                if (singleton == null)
                {
                    lock (syncObject)
                    {
                        if (singleton == null)
                        {
                            singleton = new T();
                        }
                    }
                }
                return singleton;
            }
        }
    }
}
